/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * EasyFinace.java
 *
 * Created on 2011-1-29, 19:31:26
 */
package lx_easyfinace;

import DB.DatabaseManager;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.print.PrinterException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListSelectionModel;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import lx_easyfinace.util.CalculateUtil;
import lx_easyfinace.util.DataOperateUtil;
import model.Constants;
import model.Guest;
import model.Product;
import model.Sell;
import pc.pWindwos;

/**
 *
 * @author Administrator
 */
public class EasyFinace extends javax.swing.JFrame {

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    /**
     * 已有客户
     */
    List<Guest> guestList;
    /**
     * 当前客户
     */
    private String currentGuest;
    /**
     * 数据库插入助手.
     */
    private DataOperateUtil dataOperateUtil;
    /**
     * jTable列名
     */
    private String[] columns;
    /**
     * sale_Table DefaultTableModel
     * 默认表数据模型
     */
    private DefaultTableModel customerDetailModel;
    private DefaultTableModel tempModel;
    private DefaultTableModel moreDetialModel;
    /**
     * 日期选择器
     */
    private final DatePicker datePicker = new DatePicker();
    /**
     *表选择的默认模型
     */
    private DefaultListSelectionModel dlsm;
    /**
     *当前选中Row的Row号
     */
    private int tableRowIndex;
    private int comboBoxIndex;
    private int comboBoxIndex2;
    /**
     * 产品名称 默认组合框数据模型
     */
    private DefaultComboBoxModel productNameModel;
    /**
     *产品颜色 默认组合框数据模型
     */
    private DefaultComboBoxModel productColorModel;
    /**
     * 行选择监听器.
     */
    private ListSelectionListener lsl;
    private boolean lock;
    private List<String> colorNumList;
    private String selectedRowID;
//

    /** Creates new form EasyFinace */
    public EasyFinace() {
        this.setTitle("轻松记账 1.0");

        initComponents();
        initEasyFinace();
        int x = (screenSize.width - 1024) / 2;
        int y = (screenSize.height - 768) / 2;
        this.setBounds(x, y, 1024, 768);
//        this.setSize(1024, 768);
    }

    private void initEasyFinace() {
        jDialog_AddSellRecordsDialog.setBounds(100, 100, 630, 400);
        jPanel_baseinfo.setVisible(false);
        //创建一个数据库操作的辅助类
        dataOperateUtil = new DataOperateUtil();
        createDatePicker();//不放这里也行
        initBaseData();
        initTableStyle();
    }

    /**
     * 初始化已有的基础数据
     */
    private void initBaseData() {

        //测试数据,应从数据库中读取
//        Object[] nameData = new Object[]{"", "1", "2", "3"};
//        productNameModel = new DefaultComboBoxModel(nameData);
        initProductNameList();


        //测试数据,应从数据库中读取
        Object[] colorData = new Object[]{"", "red", "yellow", "bule"};
        productColorModel = new DefaultComboBoxModel(colorData);

        initGuestList();


//        comboBox_ProductName.setModel(productNameModel);
        comboBox_ProductColor.setModel(productColorModel);

    }

    private void initProductNameList() {

        List<String> list = dataOperateUtil.getExistInfo("pname", "product");
        Object[] data = new Object[list.size()];
        for (int i = 0; i < list.size(); i++) {
            data[i] = list.get(i);
        }

        DefaultComboBoxModel model = new DefaultComboBoxModel(data);
        comboBox_ProductName.setModel(model);
    }

    /**
     * 初始化已有用户信息
     */
    private void initGuestList() {
        //获取用户信息
        guestList = dataOperateUtil.getExistGuests();

        Object[] guestData = new Object[guestList.size()];
        for (int i = 0; i < guestList.size(); i++) {
            guestData[i] = guestList.get(i).getgName();
        }

        DefaultComboBoxModel guestModel = new DefaultComboBoxModel(guestData);
        //加入ComBoBox
        comboBox_GuestName.setModel(guestModel);
    }

    /**
     * 创建一个日期选择器
     */
    private void createDatePicker() {
        datePicker.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                System.err.println("getText" + datePicker.getText());
                System.err.println("getDate" + datePicker.getDate());
            }
        });
        datePicker.setDate(new Date());
        datePicker.setDateWithAction(new Date());
        datePicker.setBounds(0, 0, 100, 25);
        panel_Date.add(datePicker);
        datePicker.repaint();
        panel_Date.repaint();
    }

    /**
     * 个性化表格
     */
    private void initTableStyle() {

        Object[][] data = new Object[][]{
            {"", "", "", "", "", "", "", "", "", ""}};


        columns = new String[]{
            "日期", "品名", "数量", "总匹数", "总米数", "单价", "金额", "已付款/退货", "未付款", "cid"
        };

        createTempTable();
        createMoreDetialTable();

        customerDetailModel = new DefaultTableModel(data, columns);
        table_CustomerDetail.setModel(customerDetailModel);

//        updateTableStyle(table_tempSellDetail);
        updateTableStyle(table_CustomerDetail);

        //行选择监听器
        lsl = new ListSelectionListener() {

            @Override
            public void valueChanged(ListSelectionEvent e) {
                if (tableRowIndex == table_CustomerDetail.getSelectedRow() && !lock) {
                    System.out.println("row:" + tableRowIndex);
//                    datePicker.setText((String) customerDetailModel.getValueAt(tableRowIndex, 0));
//                    productNameModel.setSelectedItem((String) customerDetailModel.getValueAt(tableRowIndex, 1));
//                    productColorModel.setSelectedItem((String) customerDetailModel.getValueAt(tableRowIndex, 2));

                }
                tableRowIndex = table_CustomerDetail.getSelectedRow();
            }
        };

        dlsm = new DefaultListSelectionModel();
        dlsm.addListSelectionListener(lsl);
        table_CustomerDetail.setSelectionModel(dlsm);
    }

    private void createTempTable() {

        String[] tempColumns = new String[]{
            "日期", "品名", "颜色", "数量", "单价", "金额"
        };
        tempModel = new DefaultTableModel(tempColumns, 0);
        table_tempSellDetail.setModel(tempModel);

        table_tempSellDetail.getColumnModel().getColumn(0).setPreferredWidth(100);

        //单元格自动换行
        table_tempSellDetail.setDefaultRenderer(Object.class, new TableCellTextAreaRenderer());
        table_tempSellDetail.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    }

    private void createMoreDetialTable() {
        String[] moreDetialTableColumns = new String[]{
            "日期", "品名", "颜色", "数量", "单价", "金额"
        };
        moreDetialModel = new DefaultTableModel(moreDetialTableColumns, 0);
        table_moreSellDetial.setModel(moreDetialModel);
    }

    /**
     * 设置表格格式
     */
    private void updateTableStyle(JTable table) {
        //指定列宽
        table.getColumnModel().getColumn(2).setPreferredWidth(150);
        table.getColumnModel().getColumn(2).setWidth(150);
        
        table.getColumnModel().getColumn(0).setPreferredWidth(89);
        table.getColumnModel().getColumn(0).setWidth(89);
        
        table.getColumnModel().getColumn(1).setPreferredWidth(60);
        table.getColumnModel().getColumn(1).setWidth(60);
        
        table.getColumnModel().getColumn(3).setPreferredWidth(50);
        table.getColumnModel().getColumn(3).setWidth(50);
        
        table.getColumnModel().getColumn(4).setPreferredWidth(65);
        table.getColumnModel().getColumn(4).setWidth(65);        
        
        table.getColumnModel().getColumn(5).setPreferredWidth(50);
        table.getColumnModel().getColumn(5).setWidth(50);             

//        table.updateUI();
//        table.repaint();
        hideTalbeColumn(table);
        //单元格自动换行
        table.setDefaultRenderer(Object.class, new TableCellTextAreaRenderer());
        table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

        /* 个性化表格 */
//        DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer() {
//
//            @Override
//            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
//                float jine = 0;
//                //更改指定列的颜色
//                for (int i = 0; i < table.getRowCount(); i++) {
//                    try {
//                    jine = Float.parseFloat(table.getValueAt(i, 6).toString());
//                    } catch (java.lang.NumberFormatException e) {
//                        break;
//                    }
//                    if (jine < 0) {
//                        this.setBackground(Color.red);
//                    } else {
//                        this.setBackground(Color.white);
//                    }
//                }
//
//                return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
//            }
//        };
//
//        for (int i = 0; i < table.getColumnCount(); i++) {
//            table.getColumn(table.getColumnName(i)).setCellRenderer(dtcr);
//        }

//        TableColumn tableColumn = table.getColumn("已付款/退货");
//        
//        DefaultTableCellRenderer cellRenderer = new DefaultTableCellRenderer();
//        cellRenderer.setBackground(Color.red);
//        tableColumn.setCellRenderer(cellRenderer);
    }

    private void hideTalbeColumn(JTable table) {
        TableColumn tc = table.getColumnModel().getColumn(9);
        tc.setMaxWidth(0);
        tc.setPreferredWidth(0);
        tc.setWidth(0);
        tc.setMinWidth(0);
        table.getColumnModel().getColumn(9).setPreferredWidth(0);
        table.getColumnModel().getColumn(9).setMaxWidth(0);
        table.getColumnModel().getColumn(9).setMinWidth(0);
    }

    /**
     * 测试数据库链接情况
     */
//    private void testOracleConnect() {
//        String insertSql = "INSERT INTO GUEST VALUES (3, 'TestJavaConnect', NULL, NULL)";
//        ResultSet rs = null;
//        StringBuffer strBuffer = new StringBuffer();
//        try {
//            PreparedStatement pstmt = oracleConnect.prepareStatement("SELECT * FROM GUEST");
//            rs = pstmt.executeQuery();
//            while (rs.next()) {
//                strBuffer.append(rs.getInt(1) + " ");
//                strBuffer.append(rs.getString(2) + " ");
//                strBuffer.append(rs.getString(3) + " ");
//                strBuffer.append(rs.getString(4) + " ");
//            }
//            System.out.println(strBuffer);
//        } catch (SQLException ex) {
//            Logger.getLogger(EasyFinace.class.getName()).log(Level.SEVERE, null, ex);
//        }
//    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tabbedPane_StockManager = new javax.swing.JTabbedPane();
        panel_Stock = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        table_Stock1 = new javax.swing.JTable();
        jLabel17 = new javax.swing.JLabel();
        jComboBox3 = new javax.swing.JComboBox();
        jLabel21 = new javax.swing.JLabel();
        jTextField4 = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        textField_MyName1 = new javax.swing.JTextField();
        panelStock_addNewRecord = new javax.swing.JPanel();
        button_AddStockRecord = new javax.swing.JButton();
        textField_Per_Price2 = new javax.swing.JTextField();
        textField_payed2 = new javax.swing.JTextField();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        comboBox_Desc2 = new javax.swing.JComboBox();
        panel_Date2 = new javax.swing.JPanel();
        jTextField5 = new javax.swing.JTextField();
        jComboBox4 = new javax.swing.JComboBox();
        tabbedPane_StorageManager = new javax.swing.JTabbedPane();
        panel_StorageQuery = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        table_Storage = new javax.swing.JTable();
        tabbedPane_SaleManager = new javax.swing.JTabbedPane();
        panel_CustomerDetail = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        table_CustomerDetail = new javax.swing.JTable();
        panel_CustomerTotal = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        table_moreSellDetial = new javax.swing.JTable();
        jDialog_AddSellRecordsDialog = new javax.swing.JDialog();
        panelSale_addNewRecord = new javax.swing.JPanel();
        button_AddSaleRecord = new javax.swing.JButton();
        textField_SalePerPrice = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        comboBox_ProductName = new javax.swing.JComboBox();
        textField_Quantity = new javax.swing.JTextField();
        comboBox_ProductColor = new javax.swing.JComboBox();
        jCheckBox_pishu = new javax.swing.JCheckBox();
        jCheckBox_yard = new javax.swing.JCheckBox();
        jScrollPane3 = new javax.swing.JScrollPane();
        table_tempSellDetail = new javax.swing.JTable();
        button_addSell = new javax.swing.JButton();
        textField_CustomerPayed = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        panel_Date = new javax.swing.JPanel();
        jLabel_guestName = new javax.swing.JLabel();
        jButton_clearSell = new javax.swing.JButton();
        jCheckBox_back = new javax.swing.JCheckBox();
        jDialog1_modifyAttri = new javax.swing.JDialog();
        jLabel6 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane6 = new javax.swing.JScrollPane();
        table_pname = new javax.swing.JTable();
        jPopupMenu1 = new javax.swing.JPopupMenu();
        jMenuItem_Edit = new javax.swing.JMenuItem();
        jMenuItem_Del = new javax.swing.JMenuItem();
        jDialog_EditSellRecordDialog = new javax.swing.JDialog();
        jLabel14 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        button_AddSaleRecord1 = new javax.swing.JButton();
        textField_SalePerPrice1 = new javax.swing.JTextField();
        textField_CustomerPayed1 = new javax.swing.JTextField();
        textField_Quantity1 = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jButton4 = new javax.swing.JButton();
        textField_SaleDate = new javax.swing.JTextField();
        textField_ProductName = new javax.swing.JTextField();
        textField_ProductColor = new javax.swing.JTextField();
        jhManager_Button = new javax.swing.JButton();
        kccx_Button = new javax.swing.JButton();
        entityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("jdbc:oracle:thin:@localhost:1521:XEPU").createEntityManager();
        guestQuery = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT g FROM Guest g");
        menu_Modify = new javax.swing.JMenu();
        menuItem_ModifyRecord = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        exit_MenuItem = new javax.swing.JMenuItem();
        menu_Function = new javax.swing.JMenu();
        menu_SaleManager = new javax.swing.JMenu();
        menuItem_CustomerDetail = new javax.swing.JMenuItem();
        menuItem_CustomerTotal = new javax.swing.JMenuItem();
        menu_StockManager = new javax.swing.JMenu();
        menuItem_Stock = new javax.swing.JMenuItem();
        menu_StorageManager = new javax.swing.JMenu();
        menuItem_Storage = new javax.swing.JMenuItem();
        menu_Setting = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        guestList2 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : guestQuery.getResultList();
        mainFunction_Panel = new javax.swing.JPanel();
        saleManager_Button = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        panel_Main = new javax.swing.JPanel();
        jPanel_baseinfo = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        comboBox_GuestName = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        textField_CustomerPhone = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        textField_CustomerAddrs = new javax.swing.JTextField();
        jButton_AddSellRecords = new javax.swing.JButton();
        jButton_print = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        menu_manager = new javax.swing.JMenu();
        menuItem_CustonManager = new javax.swing.JMenuItem();
        menuItem_ProductMrg = new javax.swing.JMenuItem();
        bukData = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        menuItem_AboutWe = new javax.swing.JMenuItem();

        table_Stock1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null}
            },
            new String [] {
                "日期", "品名", "颜色", "数量", "单价", "金额", "已付款/退货", "未付款"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Float.class, java.lang.Float.class, java.lang.Float.class, java.lang.Float.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane5.setViewportView(table_Stock1);

        jLabel17.setText("厂家名称:");

        jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "A厂家", "B厂家", "C厂家" }));
        jComboBox3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox3ActionPerformed(evt);
            }
        });

        jLabel21.setText("  电话:");

        jTextField4.setText("12345678900");

        jLabel22.setText("姓名:");

        textField_MyName1.setText("名字");

        button_AddStockRecord.setText("新增记录");
        button_AddStockRecord.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                button_AddStockRecordMouseClicked(evt);
            }
        });

        textField_Per_Price2.setText("per_price");

        textField_payed2.setText("payed");

        jLabel23.setText("已付款/退货");

        jLabel24.setText("单价");

        jLabel25.setText("数量");

        jLabel26.setText("颜色/色号");

        jLabel27.setText("品名");

        jLabel28.setText("日期");

        comboBox_Desc2.setEditable(true);

        javax.swing.GroupLayout panel_Date2Layout = new javax.swing.GroupLayout(panel_Date2);
        panel_Date2.setLayout(panel_Date2Layout);
        panel_Date2Layout.setHorizontalGroup(
            panel_Date2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 110, Short.MAX_VALUE)
        );
        panel_Date2Layout.setVerticalGroup(
            panel_Date2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 30, Short.MAX_VALUE)
        );

        jTextField5.setText("jTextField3");
        jTextField5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField5ActionPerformed(evt);
            }
        });

        jComboBox4.setEditable(true);

        javax.swing.GroupLayout panelStock_addNewRecordLayout = new javax.swing.GroupLayout(panelStock_addNewRecord);
        panelStock_addNewRecord.setLayout(panelStock_addNewRecordLayout);
        panelStock_addNewRecordLayout.setHorizontalGroup(
            panelStock_addNewRecordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelStock_addNewRecordLayout.createSequentialGroup()
                .addGroup(panelStock_addNewRecordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelStock_addNewRecordLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(panel_Date2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(comboBox_Desc2, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 85, Short.MAX_VALUE)
                        .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(66, 66, 66))
                    .addGroup(panelStock_addNewRecordLayout.createSequentialGroup()
                        .addGap(41, 41, 41)
                        .addComponent(jLabel28)
                        .addGap(80, 80, 80)
                        .addComponent(jLabel27)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 129, Short.MAX_VALUE)
                        .addComponent(jLabel26)
                        .addGap(79, 79, 79)))
                .addGroup(panelStock_addNewRecordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelStock_addNewRecordLayout.createSequentialGroup()
                        .addComponent(jLabel24)
                        .addGap(98, 98, 98))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelStock_addNewRecordLayout.createSequentialGroup()
                        .addComponent(textField_Per_Price2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(81, 81, 81)))
                .addGroup(panelStock_addNewRecordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel23)
                    .addGroup(panelStock_addNewRecordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(panelStock_addNewRecordLayout.createSequentialGroup()
                            .addComponent(textField_payed2, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelStock_addNewRecordLayout.createSequentialGroup()
                            .addComponent(button_AddStockRecord)
                            .addGap(107, 107, 107))))
                .addContainerGap())
            .addGroup(panelStock_addNewRecordLayout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addComponent(jLabel25)
                .addGap(39, 39, 39)
                .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 310, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(354, Short.MAX_VALUE))
        );
        panelStock_addNewRecordLayout.setVerticalGroup(
            panelStock_addNewRecordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelStock_addNewRecordLayout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(panelStock_addNewRecordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel27)
                    .addComponent(jLabel28, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel23)
                    .addComponent(jLabel24)
                    .addComponent(jLabel26))
                .addGap(5, 5, 5)
                .addGroup(panelStock_addNewRecordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelStock_addNewRecordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(comboBox_Desc2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(textField_payed2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(textField_Per_Price2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(panel_Date2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelStock_addNewRecordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelStock_addNewRecordLayout.createSequentialGroup()
                        .addComponent(jLabel25)
                        .addGap(8, 8, 8)
                        .addComponent(button_AddStockRecord))
                    .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        javax.swing.GroupLayout panel_StockLayout = new javax.swing.GroupLayout(panel_Stock);
        panel_Stock.setLayout(panel_StockLayout);
        panel_StockLayout.setHorizontalGroup(
            panel_StockLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_StockLayout.createSequentialGroup()
                .addGroup(panel_StockLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panel_StockLayout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(jLabel22)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textField_MyName1, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(51, 51, 51)
                        .addComponent(jLabel17)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(33, 33, 33)
                        .addComponent(jLabel21)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(panel_StockLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 770, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(panel_StockLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(panelStock_addNewRecord, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(15, Short.MAX_VALUE))
        );
        panel_StockLayout.setVerticalGroup(
            panel_StockLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_StockLayout.createSequentialGroup()
                .addGap(8, 8, 8)
                .addGroup(panel_StockLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel21)
                    .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17)
                    .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel22)
                    .addComponent(textField_MyName1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(panelStock_addNewRecord, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(41, Short.MAX_VALUE))
        );

        tabbedPane_StockManager.addTab("进货管理", panel_Stock);

        table_Storage.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"色丁", "红", "18+29+55"},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "品名", "颜色", "数量"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane4.setViewportView(table_Storage);

        javax.swing.GroupLayout panel_StorageQueryLayout = new javax.swing.GroupLayout(panel_StorageQuery);
        panel_StorageQuery.setLayout(panel_StorageQueryLayout);
        panel_StorageQueryLayout.setHorizontalGroup(
            panel_StorageQueryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_StorageQueryLayout.createSequentialGroup()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 717, Short.MAX_VALUE)
                .addContainerGap())
        );
        panel_StorageQueryLayout.setVerticalGroup(
            panel_StorageQueryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_StorageQueryLayout.createSequentialGroup()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 305, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(81, Short.MAX_VALUE))
        );

        tabbedPane_StorageManager.addTab("库存查询", panel_StorageQuery);

        table_CustomerDetail.setFont(new java.awt.Font("宋体", 0, 18)); // NOI18N
        table_CustomerDetail.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4", "Title 5", "Title 6", "Title 7", "Title 8"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        table_CustomerDetail.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                table_CustomerDetailMouseReleased(evt);
            }
        });
        jScrollPane2.setViewportView(table_CustomerDetail);
        table_CustomerDetail.getColumnModel().getColumn(0).setPreferredWidth(10);

        javax.swing.GroupLayout panel_CustomerDetailLayout = new javax.swing.GroupLayout(panel_CustomerDetail);
        panel_CustomerDetail.setLayout(panel_CustomerDetailLayout);
        panel_CustomerDetailLayout.setHorizontalGroup(
            panel_CustomerDetailLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_CustomerDetailLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 784, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(73, Short.MAX_VALUE))
        );
        panel_CustomerDetailLayout.setVerticalGroup(
            panel_CustomerDetailLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_CustomerDetailLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 398, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(14, Short.MAX_VALUE))
        );

        tabbedPane_SaleManager.addTab("客户明细账", panel_CustomerDetail);

        table_moreSellDetial.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "客户姓名", "总买入数量", "合计金额", "已付款", "未付款"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.Float.class, java.lang.Float.class, java.lang.Float.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane1.setViewportView(table_moreSellDetial);

        javax.swing.GroupLayout panel_CustomerTotalLayout = new javax.swing.GroupLayout(panel_CustomerTotal);
        panel_CustomerTotal.setLayout(panel_CustomerTotalLayout);
        panel_CustomerTotalLayout.setHorizontalGroup(
            panel_CustomerTotalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_CustomerTotalLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 643, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(214, Short.MAX_VALUE))
        );
        panel_CustomerTotalLayout.setVerticalGroup(
            panel_CustomerTotalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_CustomerTotalLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 291, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(121, Short.MAX_VALUE))
        );

        tabbedPane_SaleManager.addTab("更多细节", panel_CustomerTotal);

        panelSale_addNewRecord.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        panelSale_addNewRecord.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        button_AddSaleRecord.setText("添加");
        button_AddSaleRecord.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                button_AddSaleRecordMouseClicked(evt);
            }
        });
        panelSale_addNewRecord.add(button_AddSaleRecord, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 60, -1, -1));
        panelSale_addNewRecord.add(textField_SalePerPrice, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 30, 63, -1));

        jLabel11.setText("单价");
        panelSale_addNewRecord.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 10, -1, -1));

        jLabel15.setText("数量");
        panelSale_addNewRecord.add(jLabel15, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 10, -1, -1));

        jLabel10.setText("颜色/色号");
        panelSale_addNewRecord.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 10, -1, -1));

        jLabel9.setText("品名");
        panelSale_addNewRecord.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 10, -1, -1));

        comboBox_ProductName.setEditable(true);
        comboBox_ProductName.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                comboBox_ProductNameItemStateChanged(evt);
            }
        });
        panelSale_addNewRecord.add(comboBox_ProductName, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 30, 80, 20));
        panelSale_addNewRecord.add(textField_Quantity, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 30, 150, -1));

        comboBox_ProductColor.setEditable(true);
        panelSale_addNewRecord.add(comboBox_ProductColor, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 30, 80, -1));

        jCheckBox_pishu.setText("匹数");
        panelSale_addNewRecord.add(jCheckBox_pishu, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 60, 55, -1));

        jCheckBox_yard.setText("码");
        panelSale_addNewRecord.add(jCheckBox_yard, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 30, -1, -1));

        table_tempSellDetail.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        table_tempSellDetail.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                table_tempSellDetailMouseReleased(evt);
            }
        });
        jScrollPane3.setViewportView(table_tempSellDetail);

        button_addSell.setText("确定");
        button_addSell.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                button_addSellMouseClicked(evt);
            }
        });

        textField_CustomerPayed.setText("0");

        jLabel13.setText("已付款/退货");

        jLabel8.setText("日期");

        javax.swing.GroupLayout panel_DateLayout = new javax.swing.GroupLayout(panel_Date);
        panel_Date.setLayout(panel_DateLayout);
        panel_DateLayout.setHorizontalGroup(
            panel_DateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 110, Short.MAX_VALUE)
        );
        panel_DateLayout.setVerticalGroup(
            panel_DateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 29, Short.MAX_VALUE)
        );

        jLabel_guestName.setText("名字");

        jButton_clearSell.setText("清除");
        jButton_clearSell.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton_clearSellMouseClicked(evt);
            }
        });

        jCheckBox_back.setText("退货");
        jCheckBox_back.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jCheckBox_backItemStateChanged(evt);
            }
        });

        javax.swing.GroupLayout jDialog_AddSellRecordsDialogLayout = new javax.swing.GroupLayout(jDialog_AddSellRecordsDialog.getContentPane());
        jDialog_AddSellRecordsDialog.getContentPane().setLayout(jDialog_AddSellRecordsDialogLayout);
        jDialog_AddSellRecordsDialogLayout.setHorizontalGroup(
            jDialog_AddSellRecordsDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog_AddSellRecordsDialogLayout.createSequentialGroup()
                .addGroup(jDialog_AddSellRecordsDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jDialog_AddSellRecordsDialogLayout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(jLabel_guestName, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(31, 31, 31)
                        .addGroup(jDialog_AddSellRecordsDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(textField_CustomerPayed, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel13))
                        .addGap(25, 25, 25)
                        .addComponent(jCheckBox_back)
                        .addGap(47, 47, 47)
                        .addGroup(jDialog_AddSellRecordsDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jDialog_AddSellRecordsDialogLayout.createSequentialGroup()
                                .addGap(43, 43, 43)
                                .addComponent(jLabel8))
                            .addComponent(panel_Date, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(68, 68, 68))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jDialog_AddSellRecordsDialogLayout.createSequentialGroup()
                        .addGap(349, 349, 349)
                        .addComponent(jButton_clearSell, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(39, 39, 39)
                        .addComponent(button_addSell))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jDialog_AddSellRecordsDialogLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(panelSale_addNewRecord, javax.swing.GroupLayout.PREFERRED_SIZE, 476, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jDialog_AddSellRecordsDialogLayout.setVerticalGroup(
            jDialog_AddSellRecordsDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog_AddSellRecordsDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jDialog_AddSellRecordsDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jDialog_AddSellRecordsDialogLayout.createSequentialGroup()
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jDialog_AddSellRecordsDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(textField_CustomerPayed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jCheckBox_back))
                        .addGap(10, 10, 10))
                    .addGroup(jDialog_AddSellRecordsDialogLayout.createSequentialGroup()
                        .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(panel_Date, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jDialog_AddSellRecordsDialogLayout.createSequentialGroup()
                        .addComponent(jLabel_guestName, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panelSale_addNewRecord, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(14, 14, 14)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jDialog_AddSellRecordsDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(button_addSell, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton_clearSell, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(11, Short.MAX_VALUE))
        );

        jLabel6.setText("基础属性修改");

        jButton2.setText("品名");

        jButton3.setText("色号/颜色");

        table_pname.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane6.setViewportView(table_pname);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 443, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(30, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jDialog1_modifyAttriLayout = new javax.swing.GroupLayout(jDialog1_modifyAttri.getContentPane());
        jDialog1_modifyAttri.getContentPane().setLayout(jDialog1_modifyAttriLayout);
        jDialog1_modifyAttriLayout.setHorizontalGroup(
            jDialog1_modifyAttriLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog1_modifyAttriLayout.createSequentialGroup()
                .addGroup(jDialog1_modifyAttriLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jDialog1_modifyAttriLayout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addGroup(jDialog1_modifyAttriLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton3)
                            .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jDialog1_modifyAttriLayout.createSequentialGroup()
                        .addGap(38, 38, 38)
                        .addComponent(jButton2)))
                .addGap(33, 33, 33)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(62, Short.MAX_VALUE))
        );
        jDialog1_modifyAttriLayout.setVerticalGroup(
            jDialog1_modifyAttriLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog1_modifyAttriLayout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(jDialog1_modifyAttriLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jDialog1_modifyAttriLayout.createSequentialGroup()
                        .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(36, 36, 36)
                        .addComponent(jButton2)
                        .addGap(49, 49, 49)
                        .addComponent(jButton3)))
                .addContainerGap(106, Short.MAX_VALUE))
        );

        jMenuItem_Edit.setText("修改");
        jMenuItem_Edit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem_EditActionPerformed(evt);
            }
        });
        jPopupMenu1.add(jMenuItem_Edit);

        jMenuItem_Del.setText("删除");
        jMenuItem_Del.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem_DelActionPerformed(evt);
            }
        });
        jPopupMenu1.add(jMenuItem_Del);

        jDialog_EditSellRecordDialog.setBounds(new java.awt.Rectangle(0, 0, 0, 0));

        jLabel14.setText("品名");

        jLabel16.setText("颜色/色号");

        jLabel18.setText("单价");

        jLabel19.setText("已付款/退货");

        jLabel20.setText("数量");

        button_AddSaleRecord1.setText("修改");
        button_AddSaleRecord1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                button_AddSaleRecord1MouseClicked(evt);
            }
        });
        button_AddSaleRecord1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_AddSaleRecord1ActionPerformed(evt);
            }
        });

        textField_CustomerPayed1.setText("0");

        jLabel12.setText("日期");

        jButton4.setText("取消");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jDialog_EditSellRecordDialogLayout = new javax.swing.GroupLayout(jDialog_EditSellRecordDialog.getContentPane());
        jDialog_EditSellRecordDialog.getContentPane().setLayout(jDialog_EditSellRecordDialogLayout);
        jDialog_EditSellRecordDialogLayout.setHorizontalGroup(
            jDialog_EditSellRecordDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog_EditSellRecordDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jDialog_EditSellRecordDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jDialog_EditSellRecordDialogLayout.createSequentialGroup()
                        .addGroup(jDialog_EditSellRecordDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(jLabel12)
                            .addComponent(textField_SaleDate, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel18)
                            .addComponent(textField_SalePerPrice1, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jDialog_EditSellRecordDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(jLabel14)
                            .addComponent(textField_ProductName, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(textField_CustomerPayed1, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE))
                        .addGroup(jDialog_EditSellRecordDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jDialog_EditSellRecordDialogLayout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addGroup(jDialog_EditSellRecordDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(textField_Quantity1, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(textField_ProductColor, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jDialog_EditSellRecordDialogLayout.createSequentialGroup()
                                .addGap(91, 91, 91)
                                .addComponent(jLabel20))
                            .addGroup(jDialog_EditSellRecordDialogLayout.createSequentialGroup()
                                .addGap(67, 67, 67)
                                .addComponent(jLabel16)))
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jDialog_EditSellRecordDialogLayout.createSequentialGroup()
                        .addComponent(jButton4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(button_AddSaleRecord1)
                        .addGap(16, 16, 16))))
        );
        jDialog_EditSellRecordDialogLayout.setVerticalGroup(
            jDialog_EditSellRecordDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog_EditSellRecordDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jDialog_EditSellRecordDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(jLabel14)
                    .addComponent(jLabel16))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jDialog_EditSellRecordDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textField_SaleDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(textField_ProductName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(textField_ProductColor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jDialog_EditSellRecordDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jDialog_EditSellRecordDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel18)
                        .addComponent(jLabel19, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jLabel20))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jDialog_EditSellRecordDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textField_SalePerPrice1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(textField_CustomerPayed1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(textField_Quantity1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jDialog_EditSellRecordDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton4)
                    .addComponent(button_AddSaleRecord1))
                .addContainerGap())
        );

        jhManager_Button.setText("进货管理");
        jhManager_Button.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jhManager_ButtonMouseClicked(evt);
            }
        });

        kccx_Button.setText("库存查询");
        kccx_Button.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                kccx_ButtonMouseClicked(evt);
            }
        });

        menu_Modify.setText("修改");
        menu_Modify.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menu_ModifyActionPerformed(evt);
            }
        });

        menuItem_ModifyRecord.setText("修改记录");
        menu_Modify.add(menuItem_ModifyRecord);

        jMenuItem1.setText("基础属性");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        menu_Modify.add(jMenuItem1);

        jMenu1.setText("文件");

        exit_MenuItem.setText("退出");
        exit_MenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exit_MenuItemActionPerformed(evt);
            }
        });
        jMenu1.add(exit_MenuItem);

        menu_Function.setText("功能");

        menu_SaleManager.setText("销售管理");

        menuItem_CustomerDetail.setText("客户明细账");
        menu_SaleManager.add(menuItem_CustomerDetail);

        menuItem_CustomerTotal.setText("客户总账");
        menu_SaleManager.add(menuItem_CustomerTotal);

        menu_Function.add(menu_SaleManager);

        menu_StockManager.setText("进货管理");

        menuItem_Stock.setText("进货");
        menu_StockManager.add(menuItem_Stock);

        menu_Function.add(menu_StockManager);

        menu_StorageManager.setText("库存查询");

        menuItem_Storage.setText("库存");
        menu_StorageManager.add(menuItem_Storage);

        menu_Function.add(menu_StorageManager);

        menu_Setting.setText("设置");

        jMenuItem2.setText("厂家设置");
        menu_Setting.add(jMenuItem2);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setName("easy"); // NOI18N
        addWindowStateListener(new java.awt.event.WindowStateListener() {
            public void windowStateChanged(java.awt.event.WindowEvent evt) {
                formWindowStateChanged(evt);
            }
        });
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        saleManager_Button.setText("销售管理");
        saleManager_Button.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                saleManager_ButtonMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout mainFunction_PanelLayout = new javax.swing.GroupLayout(mainFunction_Panel);
        mainFunction_Panel.setLayout(mainFunction_PanelLayout);
        mainFunction_PanelLayout.setHorizontalGroup(
            mainFunction_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainFunction_PanelLayout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addComponent(saleManager_Button)
                .addContainerGap(425, Short.MAX_VALUE))
        );
        mainFunction_PanelLayout.setVerticalGroup(
            mainFunction_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainFunction_PanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(saleManager_Button, javax.swing.GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE)
                .addContainerGap())
        );

        getContentPane().add(mainFunction_Panel, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 0, 540, 80));

        jLabel1.setText("  LOGO_PIC");
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 70, 60));

        javax.swing.GroupLayout panel_MainLayout = new javax.swing.GroupLayout(panel_Main);
        panel_Main.setLayout(panel_MainLayout);
        panel_MainLayout.setHorizontalGroup(
            panel_MainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 980, Short.MAX_VALUE)
        );
        panel_MainLayout.setVerticalGroup(
            panel_MainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 500, Short.MAX_VALUE)
        );

        getContentPane().add(panel_Main, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 120, 980, 500));

        jLabel2.setText("客户姓名:");

        comboBox_GuestName.setEditable(true);
        comboBox_GuestName.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                comboBox_GuestNameItemStateChanged(evt);
            }
        });

        jLabel3.setText("电话:");

        jLabel5.setText("地址:");

        jButton_AddSellRecords.setText("新增");
        jButton_AddSellRecords.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton_AddSellRecordsMouseClicked(evt);
            }
        });

        jButton_print.setText("打印");
        jButton_print.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_printActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel_baseinfoLayout = new javax.swing.GroupLayout(jPanel_baseinfo);
        jPanel_baseinfo.setLayout(jPanel_baseinfoLayout);
        jPanel_baseinfoLayout.setHorizontalGroup(
            jPanel_baseinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 672, Short.MAX_VALUE)
            .addGroup(jPanel_baseinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel_baseinfoLayout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jLabel2)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(comboBox_GuestName, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jLabel3)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(textField_CustomerPhone, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jLabel5)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(textField_CustomerAddrs, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(28, 28, 28)
                    .addComponent(jButton_AddSellRecords)
                    .addGap(18, 18, 18)
                    .addComponent(jButton_print, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(12, Short.MAX_VALUE)))
        );
        jPanel_baseinfoLayout.setVerticalGroup(
            jPanel_baseinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 40, Short.MAX_VALUE)
            .addGroup(jPanel_baseinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel_baseinfoLayout.createSequentialGroup()
                    .addGap(13, 13, 13)
                    .addGroup(jPanel_baseinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2)
                        .addComponent(comboBox_GuestName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel3)
                        .addComponent(textField_CustomerPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel5)
                        .addComponent(textField_CustomerAddrs, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton_AddSellRecords)
                        .addComponent(jButton_print))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );

        getContentPane().add(jPanel_baseinfo, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 80, -1, 40));

        menu_manager.setText("管理");

        menuItem_CustonManager.setText("客户管理");
        menuItem_CustonManager.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItem_CustonManagerActionPerformed(evt);
            }
        });
        menu_manager.add(menuItem_CustonManager);

        menuItem_ProductMrg.setText("产品/颜色 管理");
        menuItem_ProductMrg.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItem_ProductMrgActionPerformed(evt);
            }
        });
        menu_manager.add(menuItem_ProductMrg);

        bukData.setText("备份数据库");
        bukData.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bukDataActionPerformed(evt);
            }
        });
        menu_manager.add(bukData);

        jMenuBar1.add(menu_manager);

        jMenu3.setText("帮助");

        menuItem_AboutWe.setText("关于我们");
        menuItem_AboutWe.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                menuItem_AboutWeMouseClicked(evt);
            }
        });
        menuItem_AboutWe.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItem_AboutWeActionPerformed(evt);
            }
        });
        jMenu3.add(menuItem_AboutWe);

        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void saleManager_ButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_saleManager_ButtonMouseClicked
        System.out.println("进入销售管理功能.");
        panel_Main.removeAll();
        jPanel_baseinfo.setVisible(true);


        javax.swing.GroupLayout panel_MainLayout = new javax.swing.GroupLayout(panel_Main);
        panel_Main.setLayout(panel_MainLayout);
        panel_MainLayout.setHorizontalGroup(
                panel_MainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(panel_MainLayout.createSequentialGroup().addContainerGap().addComponent(tabbedPane_SaleManager, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        panel_MainLayout.setVerticalGroup(
                panel_MainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(panel_MainLayout.createSequentialGroup().addGap(18, 18, 18).addComponent(tabbedPane_SaleManager, javax.swing.GroupLayout.PREFERRED_SIZE, 600, javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        //读入数据
//        initBaseData();

    }//GEN-LAST:event_saleManager_ButtonMouseClicked

    private void exit_MenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exit_MenuItemActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_exit_MenuItemActionPerformed

    private void jhManager_ButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jhManager_ButtonMouseClicked
        System.out.println("进入收货管理功能.");
        panel_Main.removeAll();

        javax.swing.GroupLayout panel_MainLayout = new javax.swing.GroupLayout(panel_Main);
        panel_Main.setLayout(panel_MainLayout);
        panel_MainLayout.setHorizontalGroup(
                panel_MainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(panel_MainLayout.createSequentialGroup().addContainerGap().addComponent(tabbedPane_StockManager, javax.swing.GroupLayout.DEFAULT_SIZE, 800, Short.MAX_VALUE).addContainerGap()));
        panel_MainLayout.setVerticalGroup(
                panel_MainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(panel_MainLayout.createSequentialGroup().addContainerGap().addComponent(tabbedPane_StockManager, javax.swing.GroupLayout.PREFERRED_SIZE, 394, javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));


        panel_Main.repaint();

    }//GEN-LAST:event_jhManager_ButtonMouseClicked

    private void kccx_ButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_kccx_ButtonMouseClicked
        System.out.println("库存管理");
        panel_Main.removeAll();

        javax.swing.GroupLayout panel_MainLayout = new javax.swing.GroupLayout(panel_Main);
        panel_Main.setLayout(panel_MainLayout);
        panel_MainLayout.setHorizontalGroup(
                panel_MainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(panel_MainLayout.createSequentialGroup().addContainerGap().addComponent(tabbedPane_StorageManager, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap(78, Short.MAX_VALUE)));
        panel_MainLayout.setVerticalGroup(
                panel_MainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(panel_MainLayout.createSequentialGroup().addContainerGap().addComponent(tabbedPane_StorageManager, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        panel_Main.repaint();
        //        restDialog();
//        dialog_Kc.setBounds(dialogRectangle);
//        dialog_Kc.setVisible(true);
    }//GEN-LAST:event_kccx_ButtonMouseClicked

    /**
     * 加入到JTable的同时也加入到数据库中
     * @param evt
     */
    private void button_AddSaleRecordMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_button_AddSaleRecordMouseClicked
        String pName = "--";
        String date = datePicker.getText();
        if (comboBox_ProductName.getSelectedItem().toString() != null) {
            pName = comboBox_ProductName.getSelectedItem().toString();
        }

        String colorNum = comboBox_ProductColor.getSelectedItem().toString();
        String quantity = textField_Quantity.getText();
        float perPrice = 0;
        float subtotal = 0;
        try {
            perPrice = Float.parseFloat(textField_SalePerPrice.getText());
        } catch (java.lang.NumberFormatException e) {
            System.out.println("单价输入有误,请检查");
            JOptionPane.showMessageDialog(this, "单价输入有误", "", JOptionPane.ERROR_MESSAGE);
            return;
        }
        //可能抛出java.lang.NumberFormatException
        try {
            subtotal = CalculateUtil.calculateQuantity(quantity) * perPrice;
        } catch (java.lang.NumberFormatException e) {
            System.out.println("数量输入有误");
            JOptionPane.showMessageDialog(this, "数量输入有误", "", JOptionPane.ERROR_MESSAGE);
            return;
        }
//        quantity = quantity + " = " + CalculateUtil.calculateQuantity(quantity);

        float payed = Float.parseFloat(textField_CustomerPayed.getText());
        float unpay = subtotal - payed;

        //组合记录,这种方式未必好,找找替代方式

        float[] pers = CalculateUtil.calculateQuantitys(quantity);

        Object[] records = null;
        if (jCheckBox_yard.isSelected()) {
            for (int i = 0; i < pers.length; i++) {
                records = new Object[]{
                    date, pName, colorNum, pers[i] + "y", perPrice, CalculateUtil.formatNumber(perPrice * pers[i] * 0.9144)
                };
                tempModel.addRow(records);
            }
        } else {
            for (int i = 0; i < pers.length; i++) {
                records = new Object[]{
                    date, pName, colorNum, pers[i], perPrice, perPrice * pers[i]
                };
                tempModel.addRow(records);
            }
        }
        if (isNew(pName, comboBox_ProductName)) {
            comboBox_ProductName.addItem(pName);

            try {
                dataOperateUtil.createProduct(pName, perPrice, Constants.STORAGE_UNKNOW, null);
            } catch (SQLException ex) {
                Logger.getLogger(EasyFinace.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        Product product = new Product();
        String productName = comboBox_ProductName.getSelectedItem().toString();
        product = (Product) dataOperateUtil.getDbm().getObj(new Product(), "pname", productName);
        if (isNew(colorNum, comboBox_ProductColor)) {
            comboBox_ProductColor.addItem(colorNum);
            try {
                dataOperateUtil.createColor(colorNum, product);
            } catch (SQLException ex) {
                Logger.getLogger(EasyFinace.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
//        
//        if(isNew(color, comboBox_ProductColor)) {
//                    //颜色信息
//        Color color = new Color();
//        color = (Color) dataOperateUtil.getDbm().getObj(color, "cid", String.valueOf(cid));
//        if (!color.isExist()) {
//            color.setCid(getDbm().getIDNums(color));
//            color.setPid(pid);
//            color.setColornum(colorNum);
////            color.setColordesc("红色");
////            color.setExist(true);
//        }
//        }



//        comboBox_ProductColor.addi

    }//GEN-LAST:event_button_AddSaleRecordMouseClicked

    private void formWindowStateChanged(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowStateChanged
        this.repaint();
    }//GEN-LAST:event_formWindowStateChanged

    private void jComboBox3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBox3ActionPerformed

    private void button_AddStockRecordMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_button_AddStockRecordMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_button_AddStockRecordMouseClicked

    private void jTextField5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField5ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField5ActionPerformed

    private void menuItem_AboutWeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_menuItem_AboutWeMouseClicked
        System.out.println("帮助?");
    }//GEN-LAST:event_menuItem_AboutWeMouseClicked

    private void comboBox_GuestNameItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_comboBox_GuestNameItemStateChanged
        if (comboBoxIndex == comboBox_GuestName.getSelectedIndex()) {
            currentGuest = comboBox_GuestName.getSelectedItem().toString();
            //根据当前用户名显示相应账目记录
            updateGuestDetail();
            updateMoreDetialTable();
            //当前用户的信息
            setupGuestInfo();
            if (jDialog_AddSellRecordsDialog.isShowing()) {
                showAddSellRecords();
            }
        }
        comboBoxIndex = comboBox_GuestName.getSelectedIndex();
    }//GEN-LAST:event_comboBox_GuestNameItemStateChanged

    private void updateMoreDetialTable() {
        /*
         * SELECT ts.sid,tg.gname, ts.sdate, tp.pname, tc.colornum, tsi.SIPRODUCTNUM , tsi.perprice, tsi.sisubtotal
         * FROM guest tg join sell ts on ts.gid=tg.gid join sellitem tsi on ts.sid=tsi.sid join product tp on tsi.pid=tp.pid join color tc on tp.pid=tc.pid
         * WHERE tg.gname='廖川南'
         */
//        moreDetialModel.r
        clearTableConent(moreDetialModel);
        String sql = "SELECT ts.sid,tg.gname, ts.sdate, tp.pname, tc.colornum, tsi.SIPRODUCTNUM , tsi.perprice, tsi.sisubtotal"
                + " FROM guest tg join sell ts on ts.gid=tg.gid join sellitem tsi on ts.sid=tsi.sid join product tp on tsi.pid=tp.pid join color tc on tsi.cid=tc.cid"
                + " WHERE tg.gname="
                + "'"
                + currentGuest
                + "'";
        ResultSet rs = null;
        try {
            rs = dataOperateUtil.getDbm().getResultSet(sql);
            while (rs.next()) {
                Object[] recoreds = new Object[]{
                    CalculateUtil.calculateFormatDate(rs.getDate(3)), rs.getString(4), rs.getString(5), rs.getDouble(6), rs.getDouble(7), rs.getDouble(8)
                };

                moreDetialModel.addRow(recoreds);
//                System.out.println("sid:" + rs.getInt(1));
//                System.out.println("gname" + rs.getString(2));
            }
        } catch (SQLException ex) {
            Logger.getLogger(EasyFinace.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    private void menuItem_AboutWeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItem_AboutWeActionPerformed
        System.out.println(evt.getActionCommand());
    }//GEN-LAST:event_menuItem_AboutWeActionPerformed

    private void jButton_AddSellRecordsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton_AddSellRecordsMouseClicked
        showAddSellRecords();
    }//GEN-LAST:event_jButton_AddSellRecordsMouseClicked

    private void showAddSellRecords() {
        currentGuest = (String) comboBox_GuestName.getSelectedItem();
        System.out.println(currentGuest);
        jDialog_AddSellRecordsDialog.setTitle(currentGuest);
        jDialog_AddSellRecordsDialog.setVisible(true);
        jLabel_guestName.setText(currentGuest);
    }

    private void button_addSellMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_button_addSellMouseClicked

        String confirmInfo = "";
        if (jCheckBox_back.isSelected()) {
            confirmInfo = "是退货, ";
        } else {
            confirmInfo = "不是退货, ";
        }

        if (jCheckBox_pishu.isSelected()) {
            confirmInfo = confirmInfo + "是匹数, ";
        } else {
            confirmInfo = confirmInfo + "不是匹数, ";
        }

        if (jCheckBox_yard.isSelected()) {
            confirmInfo = confirmInfo + "单位是码数";
        } else {
            confirmInfo = confirmInfo + "单位是米数";
        }

        int response = JOptionPane.showConfirmDialog(jDialog_AddSellRecordsDialog, "注意：" + confirmInfo, "确认", JOptionPane.YES_NO_CANCEL_OPTION);
        if (response == 2) {
            return;
        }
        List<Object[]> sellItemList = new ArrayList<Object[]>();
        int SELL_STATUS = Constants.SELL_STATUS_UNKNOW;
        float sellTotalPrice = 0;
        float perPrice = 0;
        float payed = 0;
        float unpayed = 0;
        String productName = null;
        boolean priceWarning = false;
        boolean isErrorPrName = false;
//        String quantity = "";
        StringBuffer quantity = new StringBuffer();

        Object[] g = new Object[]{
            currentGuest, textField_CustomerPhone.getText(), textField_CustomerAddrs.getText()
        };
        if (tempModel.getRowCount() < 1 || "".equals(currentGuest)) {
            return;
        }
        for (int i = 0; i < tempModel.getRowCount(); i++) {
            Object[] records = new Object[tempModel.getColumnCount()];
            for (int j = 0; j < tempModel.getColumnCount(); j++) {
                records[j] = tempModel.getValueAt(i, j);
                //一次添加不能有重复的品名,后来再改.
                if (j == 1) {
                    if (productName != null && !productName.equals(tempModel.getValueAt(i, j).toString())) {
                        isErrorPrName = true;
                        break;
                    }
                }
                if (j == 1) {
                    productName = tempModel.getValueAt(i, j).toString();
                }


                //一次卖货，需要单价相同。。如果不同则应该添加2次，暂时做成这样。
                if (perPrice == 0 && j == 4) {
                    perPrice = Float.parseFloat(tempModel.getValueAt(i, 4).toString());
                }
                if (perPrice != 0 && perPrice != Float.parseFloat(tempModel.getValueAt(i, 4).toString())) {
                    priceWarning = true;
                }
                //合计下价格
                if (j == 5) {
                    sellTotalPrice += Float.parseFloat(tempModel.getValueAt(i, j).toString());
                }
                //统计数量
                if (j == 3) {
//                    String str = CalculateUtil.calculateOriginQuantity(tempModel.getValueAt(i, j).toString());
                    String str = (tempModel.getValueAt(i, j).toString());
                    quantity.append(str);
                    quantity.append("+");
                }
            }
            sellItemList.add(records);
        }

        if (isErrorPrName) {
            JOptionPane.showMessageDialog(jDialog_AddSellRecordsDialog, "品名不唯一", "", JOptionPane.WARNING_MESSAGE);
            return;
        }

        String pName = (String) comboBox_ProductName.getSelectedItem();
        String date = datePicker.getText();
        if (priceWarning) {
            JOptionPane.showMessageDialog(jDialog_AddSellRecordsDialog, "注意价格", "一次销售价格需要相同", JOptionPane.WARNING_MESSAGE);
            return;
        }

        payed = Float.parseFloat(textField_CustomerPayed.getText());

        DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer() {

            @Override
            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                this.setBackground(Color.red);
                return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            }
        };

        //判断是否为退货
        if (jCheckBox_back.isSelected()) {
            SELL_STATUS = Constants.SELL_STATUS_RETURN;
            sellTotalPrice = -sellTotalPrice;
//            TableColumn tc = table_CustomerDetail.getColumn(table_CustomerDetail.getColumnName(table_CustomerDetail.getColumnCount() - 1));
        } else if (payed <= 0) {
            SELL_STATUS = Constants.SELL_STATUS_UNPAYED;
        } else if (payed > 0) {
            SELL_STATUS = Constants.SELL_STATUS_PAYED;
        }

        //判断是否是匹数
        String quantityStr = quantity.substring(0, quantity.length() - 1);
        Object[] sellRecords = null;

        if (jCheckBox_pishu.isSelected()) {
            sellRecords = new Object[]{
                date, pName, quantityStr
                + " = " + CalculateUtil.formatNumber(CalculateUtil.calculateQuantity(quantity.substring(0, quantity.length() - 1))) + "$" + quantityStr.split("\\+").length + " 匹", "", "",
                perPrice, sellTotalPrice, payed, CalculateUtil.formatNumber(sellTotalPrice - payed)
            };
        } else if (!jCheckBox_pishu.isSelected()) {
            sellRecords = new Object[]{
                date, pName, quantityStr
                + " = " + CalculateUtil.formatNumber(CalculateUtil.calculateQuantity(quantity.substring(0, quantity.length() - 1))), "", "",
                perPrice, sellTotalPrice, payed, CalculateUtil.formatNumber(sellTotalPrice - payed)
            };
        }

        //插入表格
        /* 下列代码考虑放入一个类似事务管理的功能中，要么都成功，要么都不成功(插入到表格，插入到数据库) */
        customerDetailModel.addRow(sellRecords);

        //为退货设置颜色
        if (jCheckBox_back.isSelected()) {
            TableColumn tc = table_CustomerDetail.getColumn(table_CustomerDetail.getColumnName(table_CustomerDetail.getColumnCount() - 1));
            tc.setCellRenderer(dtcr);
        }


        table_CustomerDetail.validate();
        Sell sell = dataOperateUtil.addSellRecords(g, sellRecords, SELL_STATUS);
        for (Object[] records : sellItemList) {
            try {
                //插入数据库
                if (dataOperateUtil.addSellItemRecords(g, records, sell) < 0) {
                    throw new java.lang.RuntimeException("加入数据失败,回滚");
                }

            } catch (Exception e) {
                e.printStackTrace();
//            model.removeRow(model.getRowCount());
//                System.out.println("删除新增行");
                JOptionPane.showMessageDialog(jDialog_AddSellRecordsDialog, "添加失败", "", JOptionPane.WARNING_MESSAGE);
                return;
            }

            if (isNewGuest(currentGuest)) {
                updateGuestComboBox();
            }
        }
        updateGuestDetail();
        //一切正常返回个提示
        JOptionPane.showMessageDialog(jDialog_AddSellRecordsDialog, "添加成功");
        clearTableConent(tempModel);
        updateMoreDetialTable();
        jCheckBox_back.setSelected(false);

    }//GEN-LAST:event_button_addSellMouseClicked

    private void clearTableConent(DefaultTableModel model) {
        int rowCount = model.getRowCount();
        for (int i = rowCount - 1; i >= 0; i--) {
            model.removeRow(i);
        }
    }

    private void comboBox_ProductNameItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_comboBox_ProductNameItemStateChanged
        if (comboBoxIndex2 == comboBox_ProductName.getSelectedIndex()) {
            textField_SalePerPrice.setText("0");
            textField_Quantity.setText("0");
            String currentPName = (String) comboBox_ProductName.getSelectedItem();
            String sql = "SELECT colornum FROM color WHERE pid = (SELECT pid FROM product WHERE pname=" + "'" + currentPName + "')";
            System.out.println("sql:" + sql);
            ResultSet rs = null;
            colorNumList = new ArrayList<String>();
            try {
                //TODO 根据品名找到色号
                rs = dataOperateUtil.getDbm().getResultSet(sql);
                while (rs.next()) {
                    colorNumList.add(rs.getString(1));
                }
                //        Product p = (Product) dataOperateUtil.getObj(new Product(), "pname", currentPName);
                //        System.out.println("");
                //        System.out.println("");
            } catch (SQLException ex) {
                Logger.getLogger(EasyFinace.class.getName()).log(Level.SEVERE, null, ex);
            }
            colorNumList.add(0, "");
            /*
             * 根据品名，显示相应的色号
             */
            Object[] data = new Object[colorNumList.size()];
            for (int i = 0; i < colorNumList.size(); i++) {
                data[i] = colorNumList.get(i);
            }
            productColorModel = new DefaultComboBoxModel(data);
            comboBox_ProductColor.setModel(productColorModel);
        }
        comboBoxIndex2 = comboBox_ProductName.getSelectedIndex();
    }//GEN-LAST:event_comboBox_ProductNameItemStateChanged

    private void menu_ModifyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_ModifyActionPerformed
        System.out.println("jcsx");
    }//GEN-LAST:event_menu_ModifyActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        System.out.println("jcsx");
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jButton_printActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_printActionPerformed


        table_CustomerDetail.getTableHeader().setFont(new Font("黑体", 0, 12));
        
        SimpleDateFormat f = new SimpleDateFormat("yyyy-mm-dd kk:mm");
        String showString = "客户姓名：" + currentGuest + "                                   ";
        MessageFormat mf1 = new MessageFormat(showString);
        MessageFormat mf2 = new MessageFormat("");
        try {
            table_CustomerDetail.print(JTable.PrintMode.FIT_WIDTH, mf1, new MessageFormat("第 {0}页"));
            table_CustomerDetail.getPrintable(JTable.PrintMode.NORMAL, mf1, new MessageFormat("第 {0}页"));
        } catch (PrinterException ex) {
            Logger.getLogger(EasyFinace.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton_printActionPerformed

    private void table_CustomerDetailMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_table_CustomerDetailMouseReleased
        // TODO add your handling code here:
        selectTable(table_CustomerDetail, evt);
        int x = table_CustomerDetail.getSelectedRow();
        selectedRowID = (String) table_CustomerDetail.getValueAt(x, 9);

        if ((evt.getModifiers() & MouseEvent.BUTTON3_MASK) != 0) {
            int modifiers = evt.getModifiers();
            modifiers -= MouseEvent.BUTTON3_MASK;
            modifiers |= MouseEvent.BUTTON1_MASK;
            MouseEvent ne = new MouseEvent(evt.getComponent(), evt.getID(),
                    evt.getWhen(), modifiers, evt.getX(), evt.getY(), evt.getClickCount(), false);
            table_CustomerDetail.dispatchEvent(ne);
        }
        if ((evt.getModifiers() & MouseEvent.BUTTON3_MASK) != 0
                && !evt.isControlDown() && !evt.isShiftDown()) {
            jPopupMenu1.show(table_CustomerDetail, evt.getX(), evt.getY());
        }
    }//GEN-LAST:event_table_CustomerDetailMouseReleased

    private void jMenuItem_EditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_EditActionPerformed
        // TODO add your handling code here:
        //右键弹出菜单项事件响应
        System.out.println("修改" + selectedRowID);
        jDialog_EditSellRecordDialog.setAlwaysOnTop(true);
        jDialog_EditSellRecordDialog.setVisible(true);
        int x = (screenSize.width - 530) / 2;
        int y = (screenSize.height - 200) / 2;
        jDialog_EditSellRecordDialog.setBounds(x, y, 530, 200);
    }//GEN-LAST:event_jMenuItem_EditActionPerformed

    private void button_AddSaleRecord1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_button_AddSaleRecord1MouseClicked
        // TODO add your handling code here:
}//GEN-LAST:event_button_AddSaleRecord1MouseClicked

    private void button_AddSaleRecord1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_AddSaleRecord1ActionPerformed
        // TODO add your handling code here:
        System.out.println("点击修改");
}//GEN-LAST:event_button_AddSaleRecord1ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        jDialog_EditSellRecordDialog.setVisible(false);
}//GEN-LAST:event_jButton4ActionPerformed

    private void jMenuItem_DelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_DelActionPerformed
        // TODO add your handling code here:
        // 右键弹出菜单项事件响应
        System.out.println("删除" + selectedRowID);
        int response = JOptionPane.showConfirmDialog(null, "真的要删除：" + selectedRowID, "删除", JOptionPane.YES_NO_OPTION);
        System.out.println(response);
        if (0 == response) {
            System.out.println("选择了删除");
            customerDetailModel.removeRow(tableRowIndex);
//            int sid = Integer.parseInt(customerDetailModel.getValueAt(tableRowIndex, 7).toString());
//            dataOperateUtil.getDbm().oracleConnect.prepareStatement("");
            PreparedStatement pstm;
            try {
                pstm = DatabaseManager.oracleConnect.prepareStatement("delete from sell where sid=" + selectedRowID);
                pstm.execute();
                clearTableConent(moreDetialModel);
                updateMoreDetialTable();
            } catch (SQLException ex) {
                Logger.getLogger(EasyFinace.class.getName()).log(Level.SEVERE, null, ex);
            }
            updateGuestDetail();
        } else {
            System.out.println("选择了取消");
        }
    }//GEN-LAST:event_jMenuItem_DelActionPerformed

    private void jButton_clearSellMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton_clearSellMouseClicked
        clearTableConent(tempModel);
    }//GEN-LAST:event_jButton_clearSellMouseClicked

    private void table_tempSellDetailMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_table_tempSellDetailMouseReleased
//        selectTable(table_tempSellDetail, evt);
//        int x = table_tempSellDetail.getSelectedRow();
//        selectedRowID = (String) table_tempSellDetail.getValueAt(x, 7);
//
//        if ((evt.getModifiers() & MouseEvent.BUTTON3_MASK) != 0) {
//            int modifiers = evt.getModifiers();
//            modifiers -= MouseEvent.BUTTON3_MASK;
//            modifiers |= MouseEvent.BUTTON1_MASK;
//            MouseEvent ne = new MouseEvent(evt.getComponent(), evt.getID(),
//                    evt.getWhen(), modifiers, evt.getX(), evt.getY(), evt.getClickCount(), false);
//            table_tempSellDetail.dispatchEvent(ne);
//        }
//        if ((evt.getModifiers() & MouseEvent.BUTTON3_MASK) != 0
//                && !evt.isControlDown() && !evt.isShiftDown()) {
//            jPopupMenu1.show(table_tempSellDetail, evt.getX(), evt.getY());
//        }        
    }//GEN-LAST:event_table_tempSellDetailMouseReleased

    private void menuItem_CustonManagerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItem_CustonManagerActionPerformed
        // TODO add your handling code here:
        //打开客户管理页面
//        int x = (screenSize.width - 800) / 2;
//        int y = (screenSize.height - 600) / 2;
//        jDialog_GuestManager.setBounds(x, y, 800, 600);
//        panel_Main.repaint();
//        jDialog_GuestManager.setVisible(true);
        if (GuestFrame == null) {
            GuestFrame = new JFrame();
            GuestFrame.setContentPane(new GuestD());
            GuestFrame.pack();
            GuestFrame.setLocationRelativeTo(this);
            GuestFrame.setAlwaysOnTop(true);

        }
        GuestFrame.setVisible(true);
    }//GEN-LAST:event_menuItem_CustonManagerActionPerformed

    private void menuItem_ProductMrgActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItem_ProductMrgActionPerformed
        // TODO add your handling code here:
        if (produceFrame == null) {
            produceFrame = new JFrame();
            produceFrame.setContentPane(new pWindwos());
            produceFrame.pack();
        }
        produceFrame.setLocationRelativeTo(this);
        produceFrame.setVisible(true);
    }//GEN-LAST:event_menuItem_ProductMrgActionPerformed

    private void jCheckBox_backItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jCheckBox_backItemStateChanged
    }//GEN-LAST:event_jCheckBox_backItemStateChanged

    private void bukDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bukDataActionPerformed
        // TODO add your handling code here:
//        if (sBukProcess == null) {
//            sBukProcess = new showBukProcess();
//            sBukProcess.setLocationRelativeTo(this);
//        }
//        sBukProcess.setVisible(true);
        int response = JOptionPane.showConfirmDialog(null, "备份数据库？", "备份", JOptionPane.YES_NO_OPTION);
        if (response == 0) {
            Date date = new Date();
            SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd-kk-mm");
            String filename = f.format(date).toString();
            try {
                System.out.println("开始备份");
                String cmd = "exp easy/easy@xe file=d:\\"+filename+"_easy.dmp rows=n";
                Process p = Runtime.getRuntime().exec(cmd);
                InputStream fis = p.getErrorStream();
                InputStreamReader isr = new InputStreamReader(fis);
                BufferedReader br = new BufferedReader(isr);
                String line = null;
                while ((line = br.readLine()) != null) {
                    System.out.println(line);
                }
                p.destroy();
            } catch (IOException e) {
                e.printStackTrace();
            }
            JOptionPane.showConfirmDialog(null, "备份完成", "备份", JOptionPane.OK_OPTION);
        }

    }//GEN-LAST:event_bukDataActionPerformed
    private void reflash() {
        System.out.println("refalsh");
        java.util.Collection data = guestQuery.getResultList();
        for (Object entity : data) {
            entityManager.refresh(entity);
        }
        guestList2.clear();
        guestList2.addAll(data);
        panel_Main.repaint();
        System.out.println("refalsh end");
        initGuestList();
    }

    /**
     * 是否新客户
     * @param gName
     * @return
     */
    private boolean isNewGuest(String gName) {
        for (Guest g : guestList) {
            if (g.getgName().equals(gName)) {
                return false;
            }
        }
        return true;
    }

    /**
     * 是否是新属性
     * @param str
     * @param comBox
     * @return 
     */
    private boolean isNew(String str, JComboBox comBox) {
        int count = comBox.getItemCount();
        for (int i = 0; i < count; i++) {
            String exit = comBox.getItemAt(i).toString();
            if (exit.equals(str)) {
                return false;
            }
        }
        return true;
    }

    /**
     * 刷新用户信息
     */
    private void setupGuestInfo() {
        for (Guest g : guestList) {
            if (g.getgName().equals(currentGuest)) {
                textField_CustomerPhone.setText(g.getgPhone());
                textField_CustomerAddrs.setText(g.getgAddress());
                break;
            }
        }
    }

    private void refresh() {
    }

    /**
     * 当有新客户,更新一下显示列表
     */
    private void updateGuestComboBox() {
//        guestList2
        Guest newGuest = new Guest();
        newGuest.setgName(currentGuest);
        newGuest.setgPhone(textField_CustomerPhone.getText());
        newGuest.setgAddress(textField_CustomerAddrs.getText());
        guestList.add(newGuest);
        comboBox_GuestName.addItem(newGuest);
    }

    /**
     * 更新用户账目明细
     * 名字没取好。。
     */
    private void updateGuestDetail() {

//            System.out.println("change guest");

        System.out.println(currentGuest);

        List<String> dataList = dataOperateUtil.getData(currentGuest);
        Object[][] data = new Object[dataList.size()][];

        int i = 0;
        double lastUnPay = 0;
        int totalPishu = 0;
        int curPshu = 0;
        double totalMishu = 0;
        float curMishu = 0;
        for (String s : dataList) {
            String[] row = s.split(",");

            lastUnPay = lastUnPay + Double.parseDouble(row[6].trim());
            String[] strs = row[2].split("\\$");
//            if (strs.length > 1) {
//                totalPishu = totalPishu + Integer.parseInt(strs[1].substring(0, 1));
//            }
            //退货的处理
            if (Integer.parseInt(row[8].trim()) == Constants.SELL_STATUS_RETURN) {
                curMishu = -CalculateUtil.calculateQuantity(CalculateUtil.calculateOriginQuantity(strs[0]));
                if (strs.length > 1) {
                    curPshu = -Integer.parseInt(strs[1].substring(0, strs[1].length() - 1).trim());
                }
            } else {
                curMishu = CalculateUtil.calculateQuantity(CalculateUtil.calculateOriginQuantity(strs[0]));
                if (strs.length > 1) {
                    curPshu = Integer.parseInt(strs[1].substring(0, strs[1].length() - 1).trim());
                }
            }
            totalMishu = totalMishu + curMishu;
            totalPishu = totalPishu + curPshu;

            DecimalFormat df = new DecimalFormat(".00");
            Object[] temp = new Object[]{
                /*0日期*/row[0].trim(), /*1品名*/ row[1].trim(), /*2数量*/ row[2].trim(), /*3总匹数*/ totalPishu + "匹",
                /*4总米数*/ df.format(totalMishu), /*5单价*/ row[3].trim(), /*6金额*/ (row[4]), /*7已付款*/ (row[5]), /*8未付款*/ df.format(lastUnPay), /*9sid*/ row[7]
            };
            data[i] = temp;
            i++;
            curMishu = 0;
            curPshu = 0;
        }
        lock = true;
        customerDetailModel.setDataVector(data, columns);
        lock = false;



        updateTableStyle(table_CustomerDetail);

    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new EasyFinace().setVisible(true);
            }
        });
    }

    /**
     * 选择jtable鼠标位置行
     * @param jTable
     * @param e 
     */
    private void selectTable(JTable jTable, MouseEvent e) {
        //获得行
        int row = jTable.rowAtPoint(new Point(e.getX(), e.getY()));
        //设置该行为选中状态
        if (row != -1) {
            jTable.getSelectionModel().setSelectionInterval(row, row);
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem bukData;
    private javax.swing.JButton button_AddSaleRecord;
    private javax.swing.JButton button_AddSaleRecord1;
    private javax.swing.JButton button_AddStockRecord;
    private javax.swing.JButton button_addSell;
    private javax.swing.JComboBox comboBox_Desc2;
    private javax.swing.JComboBox comboBox_GuestName;
    private javax.swing.JComboBox comboBox_ProductColor;
    private javax.swing.JComboBox comboBox_ProductName;
    private javax.persistence.EntityManager entityManager;
    private javax.swing.JMenuItem exit_MenuItem;
    private java.util.List<lx_easyfinace.Guest> guestList2;
    private javax.persistence.Query guestQuery;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton_AddSellRecords;
    private javax.swing.JButton jButton_clearSell;
    private javax.swing.JButton jButton_print;
    private javax.swing.JCheckBox jCheckBox_back;
    private javax.swing.JCheckBox jCheckBox_pishu;
    private javax.swing.JCheckBox jCheckBox_yard;
    private javax.swing.JComboBox jComboBox3;
    private javax.swing.JComboBox jComboBox4;
    private javax.swing.JDialog jDialog1_modifyAttri;
    private javax.swing.JDialog jDialog_AddSellRecordsDialog;
    private javax.swing.JDialog jDialog_EditSellRecordDialog;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabel_guestName;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem_Del;
    private javax.swing.JMenuItem jMenuItem_Edit;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel_baseinfo;
    private javax.swing.JPopupMenu jPopupMenu1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JButton jhManager_Button;
    private javax.swing.JButton kccx_Button;
    private javax.swing.JPanel mainFunction_Panel;
    private javax.swing.JMenuItem menuItem_AboutWe;
    private javax.swing.JMenuItem menuItem_CustomerDetail;
    private javax.swing.JMenuItem menuItem_CustomerTotal;
    private javax.swing.JMenuItem menuItem_CustonManager;
    private javax.swing.JMenuItem menuItem_ModifyRecord;
    private javax.swing.JMenuItem menuItem_ProductMrg;
    private javax.swing.JMenuItem menuItem_Stock;
    private javax.swing.JMenuItem menuItem_Storage;
    private javax.swing.JMenu menu_Function;
    private javax.swing.JMenu menu_Modify;
    private javax.swing.JMenu menu_SaleManager;
    private javax.swing.JMenu menu_Setting;
    private javax.swing.JMenu menu_StockManager;
    private javax.swing.JMenu menu_StorageManager;
    private javax.swing.JMenu menu_manager;
    private javax.swing.JPanel panelSale_addNewRecord;
    private javax.swing.JPanel panelStock_addNewRecord;
    private javax.swing.JPanel panel_CustomerDetail;
    private javax.swing.JPanel panel_CustomerTotal;
    private javax.swing.JPanel panel_Date;
    private javax.swing.JPanel panel_Date2;
    private javax.swing.JPanel panel_Main;
    private javax.swing.JPanel panel_Stock;
    private javax.swing.JPanel panel_StorageQuery;
    private javax.swing.JButton saleManager_Button;
    private javax.swing.JTabbedPane tabbedPane_SaleManager;
    private javax.swing.JTabbedPane tabbedPane_StockManager;
    private javax.swing.JTabbedPane tabbedPane_StorageManager;
    private javax.swing.JTable table_CustomerDetail;
    private javax.swing.JTable table_Stock1;
    private javax.swing.JTable table_Storage;
    private javax.swing.JTable table_moreSellDetial;
    private javax.swing.JTable table_pname;
    private javax.swing.JTable table_tempSellDetail;
    private javax.swing.JTextField textField_CustomerAddrs;
    private javax.swing.JTextField textField_CustomerPayed;
    private javax.swing.JTextField textField_CustomerPayed1;
    private javax.swing.JTextField textField_CustomerPhone;
    private javax.swing.JTextField textField_MyName1;
    private javax.swing.JTextField textField_Per_Price2;
    private javax.swing.JTextField textField_ProductColor;
    private javax.swing.JTextField textField_ProductName;
    private javax.swing.JTextField textField_Quantity;
    private javax.swing.JTextField textField_Quantity1;
    private javax.swing.JTextField textField_SaleDate;
    private javax.swing.JTextField textField_SalePerPrice;
    private javax.swing.JTextField textField_SalePerPrice1;
    private javax.swing.JTextField textField_payed2;
    // End of variables declaration//GEN-END:variables
    private GuestD jDialog_GuestManager;
    private JFrame GuestFrame;
    private JFrame produceFrame;
    private showBukProcess sBukProcess;
//    private color.ColorD colorD;
//    private product.ProductD productD;
}
